<template>
  <h2>文章</h2>
  <h2>{{$route.query.name}}</h2>
  <h2>{{$route.query.keyword}}</h2>
</template>

<script>

import {useRoute,useRouter,onBeforeRouteLeave} from "vue-router";

export default {
  name: "article",
  setup(){
    let route = useRoute();
    let router = useRouter();
    console.log('name=>' + route.query.name);
    console.log('keyword=>' + route.query.keyword);
    //倒计时
    // setTimeout(()=>{
    //   router.push({path:'/routerapi/article',query:{'name':9999,'keyword':6666}});
    // },5000)
    //导航守卫：组件级
    onBeforeRouteLeave((to,from)=>{
      let isOk = window.confirm(`你确定要从${from.fullPath}到${to.fullPath}`);
      if(!isOk) return false;
    });
  }
}
</script>

<style scoped>

</style>